package main

import "fmt"

//golang 中基本数据类型转换
func main() {

	//只能显示转换 不能自动转换

	var i int = 42
	//var f float32=i //cannot use i (type int) as type float32 in assignment
	var f float32 = float32(42)

	fmt.Println(i)
	fmt.Println(f)

	var i2 int64 = 123123
	//低精度==》高精度
	var i3 int32 = int32(i2)
	fmt.Printf("%v,%T\n", i3, i3)
	fmt.Printf("%v,%T\n", i2, i2)
	//高精度==低精度
	var i4 int64 = int64(i2)
	fmt.Printf("%v,%T\n", i4, i4)
	fmt.Printf("%v,%T\n", i2, i2)

	//结果按照溢出处理
	var i5 int8 = int8(i4)
	fmt.Printf("%v,%T\n", i5, i5)

	//注意事项

	//测试题

}
